#pragma once

#include "GBTreeCtrlButton.h"

class CGBTreeCtrl : public CTreeCtrl
{
	DECLARE_DYNAMIC(CGBTreeCtrl)

public:
	CGBTreeCtrl();
	virtual ~CGBTreeCtrl();

private:

	void CreateButtonForItem(HTREEITEM hItem);
	void DestoryOldButtonForItem();

    void SetItemImageToExpanded(HTREEITEM hItem);
    void SetItemImageToCollaseped(HTREEITEM hItem);

    void CleanItemData();
    void DeleteBranchData( HTREEITEM hti);

public:
    virtual void PreSubclassWindow();
    virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;

private:

    CRect m_rect;						// The client rect when drawing
    int   m_h_offset;					// 0... -x (scroll offset)
    int   m_h_size;						// width of unclipped window
    int   m_v_offset;					// 0... -y (scroll offset)
    int   m_v_size;						// height of unclipped window

	CGBTreeCtrlButton	*m_wndTreeButton;
	HTREEITEM			m_hControlItem;
protected:
	DECLARE_MESSAGE_MAP()
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPaint();

    afx_msg void OnAddFaveriate();
	
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
    afx_msg void OnItemExpanding(NMHDR* pNMHDR, LRESULT* pResult);

    afx_msg BOOL OnItemToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult );

    afx_msg void OnDestroy();
};


